package com.qolome.dao;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.time.LocalDateTime;

import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "user")
public class User extends Model<User> implements Serializable {
    /**
     * UID
     */
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;

    /**
     * 姓名
     */
    @TableField(value = "name")
    private String name;

    /**
     * 年龄
     */
    @TableField(value = "age",fill = FieldFill.UPDATE)
    private Integer age;

    /**
     * 邮箱
     */
    @TableField(value = "email")
    private String email;

    /**
     * 直属上级
     */
    @TableField(value = "manager_id")
    private Long managerId;

    /**
     * 创建时间
     */
    @TableField(value = "create_time",fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 修改时间
     */
    @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    /**
     * 版本
     * 增加乐观锁注解
     */
    @Version
    @TableField(value = "version")
    private Integer version;

    /**
     * 删除表示
     */
    @TableField(value = "deleted",select = false)
    @TableLogic
    private Boolean deleted;

    /**
     * 创建人
     */
    @TableField(value = "creator_id",fill = FieldFill.INSERT)
    private Long creatorId;

    /**
     * 修改人
     */
    @TableField(value = "updator_id",fill = FieldFill.INSERT_UPDATE)
    private Long updatorId;

    private static final long serialVersionUID = 1L;

    public static final String COL_ID = "id";

    public static final String COL_NAME = "name";

    public static final String COL_AGE = "age";

    public static final String COL_EMAIL = "email";

    public static final String COL_MANAGER_ID = "manager_id";

    public static final String COL_CREATE_TIME = "create_time";

    public static final String COL_UPDATE_TIME = "update_time";

    public static final String COL_VERSION = "version";

    public static final String COL_DELETED = "deleted";

    public static final String COL_CREATOR_ID = "creator_id";

    public static final String COL_UPDATOR_ID = "updator_id";

    public static UserBuilder builder () {
        return new UserBuilder ();
    }
}